#include"task.h"

void Operation::setImg(Mat src)
{
    _src = src;
}
ArmorOperation::ArmorOperation()
{
    _arm = new ArmorDetector();
    _arm->setEnemyColor(BLUE);
}

int ArmorOperation::armorType()
{
    return _arm->getArmorType();
}

ArmorOperation::~ArmorOperation()
{
    delete _arm;
}


bool ArmorOperation::armCenter() 
{
    _arm->loadImg(_src);
    int findEnemy = _arm->detect();
    if(findEnemy==ArmorDetector::ARMOR_NO)
    {
        return false;
    }
    else
    {
        // ArmorDetector arm = &_arm;
        // _center = _arm->getCenterPoint(arm);
        return true;
    }
}
Point2f ArmorOperation::shootCenter()
{
    if(!armCenter())
    {
        return Point2f(0,0);
    }
    else
    {
        Point offset = cv::Point(0,0);
        offsetSolve solver(_center,0);
        offset  = solver.getoffset();
        return offset;
    }
}
BuffOperation::BuffOperation()
{
    _buff = new BuffDetector();
}

BuffOperation::~BuffOperation()
{
    delete _buff;
}

Point2f BuffOperation::shootCenter()
{

}

Point2f NoTaskOperation::shootCenter()
{
    return Point2f(320,240);
}


Operation *ArmorShootFactory::creatTask()
{
    return new ArmorOperation();
}

